﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HBKY.Shop.Common.Helper
{
    public static class SerchTimeTypeHelper
    {
        public static TimeFrameModel GetTimeFrame(this SerchTimeType? serchTimeType)
        {
            TimeFrameModel rangeTime = new TimeFrameModel() { StartTime = DateTime.Now, EndTime = DateTime.Now };
            switch (serchTimeType)
            {
                case SerchTimeType.NearlyOneweek:
                    rangeTime.StartTime = rangeTime.StartTime.AddDays(-7);
                    return rangeTime;
                case SerchTimeType.NearlyOneMonth:
                    rangeTime.StartTime = rangeTime.StartTime.AddMonths(-1);
                    return rangeTime;
            }
            return default;
        }
    }
   
    /// <summary>
    /// 时间范围
    /// </summary>
    public class TimeFrameModel
    { 
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }
    }

    //数据日期搜索
    public enum SerchTimeType
    {
        [Description("近一周")] NearlyOneweek = 1,
        [Description("近一月")] NearlyOneMonth = 2,
    }

}
